from . import __version__ as app_version

app_name = "srm"
app_title = "SRM"
app_publisher = "hzmes"
app_description = "Supplier Relationship Management"
app_icon = "octicon octicon-file-directory"
app_color = "grey"
app_email = "13556209635@139.com"
app_license = "MIT"


fixtures = [
	# 同步的配置,以物料主数据,供应商主数据,采购订单举例
	{
		"doctype": "ERP Sync Config",
        "filters": [
            [
                "form_id",
                "in",
                (
                    "BD_MATERIAL", "PUR_PurchaseOrder", "BD_Supplier"
                ),
            ]
        ]
	},
	# 计量单位
	{"doctype": "SRM UOM",},
	# 供应商分组
	{"doctype": "SRM Supplier Group",},
	# 供应商分类
	{"doctype": "SRM Supplier Category",},
	# 供应商管理状态
	{"doctype": "SRM Supplier Managestatus",},
	# SRM自定义允许模块组
	{"doctype": "Module Profile",},
	# 物料分组,一级分组
	{
		"doctype": "SRM Material Group",
        "filters": [
            [
                "parent_srm_material_group",
                "in",
                (
                    ""
                )
            ]
        ]
	},
	# 付款方式
	{"doctype": "SRM Payment Mode",},
	# 结算方式
	{"doctype": "SRM SettleStyle",},
	# 公司规模
	{"doctype": "SRM Company Size",},
	# 公司规模
	{"doctype": "SRM Company Property",},
	# 公司性质
	{"doctype": "SRM Company Property",},
	# 公司类别
	{"doctype": "SRM Company Nature",},		
]
# Includes in <head>
# ------------------

# include js, css files in header of desk.html
# app_include_css = "/assets/srm/css/srm.css"
# app_include_js = "/assets/srm/js/srm.js"
app_include_js = "srm.bundle.js"

# include js, css files in header of web template
# web_include_css = "/assets/srm/css/srm.css"
# web_include_js = "/assets/srm/js/srm.js"

# include custom scss in every website theme (without file extension ".scss")
# website_theme_scss = "srm/public/scss/website"

# include js, css files in header of web form
# webform_include_js = {"doctype": "public/js/doctype.js"}
# webform_include_css = {"doctype": "public/css/doctype.css"}

# include js in page
# page_js = {"page" : "public/js/file.js"}

# include js in doctype views
# doctype_js = {"doctype" : "public/js/doctype.js"}
# doctype_list_js = {"doctype" : "public/js/doctype_list.js"}
# doctype_tree_js = {"doctype" : "public/js/doctype_tree.js"}
# doctype_calendar_js = {"doctype" : "public/js/doctype_calendar.js"}

# Home Pages
# ----------

# application home page (will override Website Settings)
# home_page = "login"

# website user home page (by Role)
# role_home_page = {
#	"Role": "home_page"
# }

# Generators
# ----------

# automatically create page for each record of this doctype
# website_generators = ["Web Page"]

# Installation
# ------------

# before_install = "srm.install.before_install"
# after_install = "srm.install.after_install"

# Uninstallation
# ------------

# before_uninstall = "srm.uninstall.before_uninstall"
# after_uninstall = "srm.uninstall.after_uninstall"

# Desk Notifications
# ------------------
# See frappe.core.notifications.get_notification_config

# notification_config = "srm.notifications.get_notification_config"

# Permissions
# -----------
# Permissions evaluated in scripted ways

# permission_query_conditions = {
#	"Event": "frappe.desk.doctype.event.event.get_permission_query_conditions",
# }
#

permission_query_conditions = {
	"SRM Sample Request": "srm.srm.doctype.srm_sample_request.srm_sample_request.get_permission_query_conditions",
	"SRM Purchase Order": "srm.srm.doctype.srm_purchase_order.srm_purchase_order.get_permission_query_conditions",
	"SRM Supply Plan Of Supplier": "srm.srm.doctype.srm_supply_plan_of_supplier.srm_supply_plan_of_supplier.get_permission_query_conditions",
# "SRM Supply Plan Of Supplier": "srm.srm.doctype.srm_supply_plan_of_supplier.srm_supply_plan_of_supplier.get_permission_query_conditions",
}
# has_permission = {
#	"Event": "frappe.desk.doctype.event.event.has_permission",
# }

# DocType Class
# ---------------
# Override standard doctype classes

# override_doctype_class = {
#	"ToDo": "custom_app.overrides.CustomToDo"
# }

# Document Events
# ---------------
# Hook on document methods and events

# doc_events = {
#	"*": {
#		"on_update": "method",
#		"on_cancel": "method",
#		"on_trash": "method"
#	}
# }

# Scheduled Tasks
# ---------------

scheduler_events = {
	"cron": {
		"0/5 * * * *": [
			# 从ERP同步物料
			"srm.srm.doctype.srm_server_config.srm_server_config.sync_material_from_erp",
		],
		"0/8 * * * *": [
			# 同步[供应商导入审批单]至OA门户
			"srm.srm.doctype.srm_server_config.srm_server_config.schedule_sync_to_oa_workfolw",
		],
		"0/10 * * * *": [
			# 从ERP同步采购PO
			"srm.srm.doctype.srm_server_config.srm_server_config.sync_po_from_erp",
		],
		"38 05 * * *": [
			# 从ERP同步货源清单
			"srm.srm.doctype.srm_server_config.srm_server_config.sync_sourcebill_from_erp",
			# 2023-12-03: 同步采购入库单
			"srm.srm.doctype.srm_server_config.srm_server_config.sync_instock_from_erp"
		],
		"36 06 * * *": [
			# 2023-12-02优化: 每天06:36把180天前的邮件队列删除100条记录
			"srm.srm.doctype.srm_server_config.srm_server_config.auto_delete_email_queue",
		],
		"33 01 * * *": [
			# 每天02:33从ERP同步未关闭的PO一次,以保证单据状态和订单行的相关字段
			"srm.srm.doctype.srm_server_config.srm_server_config.new_day_sync_po_from_erp0",
		],
		"33 02 * * *": [
			# 每天02:33从ERP同步未关闭的PO一次,以保证单据状态和订单行的相关字段
			"srm.srm.doctype.srm_server_config.srm_server_config.new_day_sync_po_from_erp1",
		],
		"33 04 * * *": [
			# 每天02:33从ERP同步未关闭的PO一次,以保证单据状态和订单行的相关字段
			"srm.srm.doctype.srm_server_config.srm_server_config.new_day_sync_po_from_erp2",
		],
		"0/15 * * * *": [
			# 从ERP同步采购订单变更单
			"srm.srm.doctype.srm_server_config.srm_server_config.sync_po_change_from_erp",
		],
		"36 02 * * *": [
			# 每天02:36从ERP同步采购价目表记录
			"srm.srm.doctype.srm_server_config.srm_server_config.sync_pricecategory_from_erp",
		],
		"36 03 * * *": [
			# 每天03:36从ERP同步物料同步一次以确保规格型号,物料名称可保持一致性
			"srm.srm.doctype.srm_server_config.srm_server_config.new_day_sync_material_from_erp",
		],
		"36 04 * * *": [
			# 每天定期匹配ERP供应商名称,有变更则改之
			"srm.srm.doctype.srm_server_config.srm_server_config.day_sync_supplier_from_erp",
		],
		"0/30 * * * *": [
			# ERP手工补录的答交场景: 只同步到SRM作为送货依据,无需答交互动
			"srm.srm.doctype.srm_server_config.srm_server_config.sync_plan_of_supplier_from_erp_add",
		],
		"0/150 * * * *": [
			# 从ERP同步采购交期回复表-采购员 安排后台事务 2023-03-08
			"srm.srm.doctype.srm_server_config.srm_server_config.sync_plan_of_supplier_from_erp",
		]
	},
	"hourly": [
		"srm.srm.doctype.srm_public_email.srm_public_email.send_email_hourly"
	],
}

# scheduler_events = {
# 	# "all": [
# 	# 	"srm.tasks.all"
# 	# ],
# 	# "daily": [
# 	# 	"srm.tasks.daily"
# 	# ],
# 	"hourly": [
# 		"srm.srm.doctype.srm_public_email.srm_public_email.send_email_hourly"
# 	],
# 	# "weekly": [
# 	# 	"srm.tasks.weekly"
# 	# ]
# 	# "monthly": [
# 	# 	"srm.tasks.monthly"
# 	# ]
# }

# Testing
# -------

# before_tests = "srm.install.before_tests"

# Overriding Methods
# ------------------------------
#
# override_whitelisted_methods = {
#	"frappe.desk.doctype.event.event.get_events": "srm.event.get_events"
# }
#
# each overriding function accepts a `data` argument;
# generated from the base implementation of the doctype dashboard,
# along with any modifications made in other Frappe apps
# override_doctype_dashboards = {
#	"Task": "srm.task.get_dashboard_data"
# }

# exempt linked doctypes from being automatically cancelled
#
# auto_cancel_exempted_doctypes = ["Auto Repeat"]


# User Data Protection
# --------------------

user_data_fields = [
	{
		"doctype": "{doctype_1}",
		"filter_by": "{filter_by}",
		"redact_fields": ["{field_1}", "{field_2}"],
		"partial": 1,
	},
	{
		"doctype": "{doctype_2}",
		"filter_by": "{filter_by}",
		"partial": 1,
	},
	{
		"doctype": "{doctype_3}",
		"strict": False,
	},
	{
		"doctype": "{doctype_4}"
	}
]

# Authentication and authorization
# --------------------------------

# auth_hooks = [
#	"srm.auth.validate"
# ]

